import { useEffect, useState } from "react";
import { mockData } from "../mock-data";
import { useParams } from "react-router-dom";
import './index.scss'

import HtmlContent from "@/components/html-content/index";

export default function CompanyNewsDetail() {
  const { id } = useParams(); // 获取路由参数
  const [currentItem, setCurrentItem] = useState(null);
  // 页面初始化时，开始渲染图表
  useEffect(() => {
    const getItem = mockData.find((item) => item.id === id);
    setCurrentItem(getItem);
  }, []);
  return (
    <div className="company-news-detail">
      <h2>{currentItem?.title}</h2>
      <p className="header-img-area" >
      <img src={currentItem?.headerImg} alt="" className="header-img" />
      </p>
      <HtmlContent html={currentItem?.shortNews} />
      <HtmlContent html={currentItem?.news} />
    </div>
  );
}
